/*
 * @Description: 
 * @Author: fhw
 * @Date: 2023-01-10 10:30:12
 */
import { Body, Controller, Get, HttpCode, Post, Query, UseFilters, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { ApiResponse, ApiOperation, ApiTags, ApiBody, ApiQuery, ApiBearerAuth } from '@nestjs/swagger';
import { IdDto } from 'src/common/dto/dto';
import { HttpExceptionFilter } from 'src/http-exception.filter';
import { CreateHistorySessionDto, DeleteHistorySessionDto, GetHistorySessionDto, UpdateDoNotDisturbDto } from './dto/history-session.dto';
import { HistorySessionService } from './history-session.service';

@Controller('history-session')
@ApiTags('历史会话')
@ApiBearerAuth() // swagger文档设置token
export class HistorySessionController {
  constructor(private readonly historySessionService: HistorySessionService) { }
  @Get('/getHistorySession')
  @ApiResponse({
    status: 200,
    description: '获取历史会话',
    type: GetHistorySessionDto,
  })
  @ApiOperation({ summary: '获取历史会话', operationId: 'getHistorySession' })
  @UseGuards(AuthGuard('jwt'))//jwt策略，身份鉴权
  async getHistorySession(@Query() params: GetHistorySessionDto) {
    return await this.historySessionService.getHistorySession(params)
  }

  @HttpCode(200)
  @Post('/createHistorySession')
  @ApiQuery({
    description: '创建历史会话',
    type: CreateHistorySessionDto,
  })
  @ApiBody({
    description: '创建历史会话',
    type: CreateHistorySessionDto,
  })
  @ApiOperation({ summary: '创建历史会话', operationId: 'createHistorySession'  })
  @UseFilters(new HttpExceptionFilter())
  @UseGuards(AuthGuard('jwt'))//jwt策略，身份鉴权
  async createHistorySession(@Body() params: CreateHistorySessionDto) {
    return await this.historySessionService.createHistorySession(params)
  }

  @HttpCode(200)
  @Post('/deleteHistorySession')
  @ApiQuery({
    description: '删除历史会话',
    type: DeleteHistorySessionDto,
  })
  @ApiBody({
    description: '删除历史会话',
    type: DeleteHistorySessionDto,
  })
  @ApiOperation({ summary: '删除历史会话', operationId: 'deleteHistorySession'  })
  @UseFilters(new HttpExceptionFilter())
  @UseGuards(AuthGuard('jwt'))//jwt策略，身份鉴权
  async deleteHistorySession(@Body() params: DeleteHistorySessionDto) {
    return await this.historySessionService.deleteHistorySession(params)
  }

  @HttpCode(200)
  @Post('/updateDoNotDisturb')
  @ApiQuery({
    description: '消息免打扰',
    type: UpdateDoNotDisturbDto,
  })
  @ApiBody({
    description: '消息免打扰',
    type: UpdateDoNotDisturbDto,
  })
  @ApiOperation({ summary: '消息免打扰', operationId: 'updateDoNotDisturb'  })
  @UseFilters(new HttpExceptionFilter())
  @UseGuards(AuthGuard('jwt'))//jwt策略，身份鉴权
  async updateDoNotDisturb(@Body() params: UpdateDoNotDisturbDto) {
    return await this.historySessionService.updateDoNotDisturb(params)
  }
}
